let $db := doc("xp")
return 
	for $xp in $db/ranking/globalResults/resultsByXp//xp
	return
		insert node 
			<xp>
				{$xp/@id}
				{ 
				for $user in $xp//user
				order by sum($user/notation/points) descending
				return
					<user>
						<name>{$user/name/text()}</name>
						<points>{sum($user/notation/points)}</points>
						<rank/>
					</user>
				}
			</xp>
		into $db/ranking/rankings/globalRanking
			